import React, {Component} from 'react';
import HeadArea from './HeadArea';
import SearchArea from './SearchArea';
import TabArea from './TabArea';
import BodyArea from './BodyArea';
import HeadCenterCustom from './HeadCenterCustom';
import ButtonGroup from '../profile/btn-group/ButtonGroup';
import NonstandardButtonGroup from '../profile/btn-group/NonstandardButtonGroup';


/**
 * 主子表-列表界面结构布局
 */
class BillListStyle extends Component {

    static HeadArea = HeadArea;
    static SearchArea = SearchArea;
    static TabArea = TabArea;
    static BodyArea = BodyArea;
    static HeadCenterCustom = HeadCenterCustom;
    static ButtonGroup = ButtonGroup;
    static NonstandardButtonGroup = NonstandardButtonGroup;

    constructor() {
        super();
        window._ssc_gy_profile = {

        }
    }
    render() {
        
        let HeadArea,SearchArea,TabArea,BodyArea;
        let otherJsx = [];

        let {children, id, ...otherProps} = this.props;
        window._ssc_gy_profile = {
            ...window._ssc_gy_profile,
            ncProps: otherProps
        }

        React.Children.forEach(this.props.children, (child) => {
            if (child && child.type) {
                if (child.type.comName) {
                    switch (child.type.comName) { //此处获取函数名不兼容。后续处理
                        case 'BillList.HeadArea':
                            HeadArea = child;
                            break;
                        case 'BillList.SearchArea':
                            SearchArea = child
                            break;
                        case 'BillList.TabArea':
                            TabArea = child;
                            break;
                        case 'BillList.BodyArea':
                            BodyArea = child;
                            break;
                        default:
                            otherJsx.push(child);
                    }
                } else {
                    otherJsx.push(child);
                }
            } else {
                otherJsx.push(child);
            }

        });
        return (
            <div id={id} className="nc-bill-list">
                {HeadArea}
                {SearchArea}
                {TabArea}
                {BodyArea}
                {otherJsx}
            </div>
        )
    }
}

export default BillListStyle;
